package com.bestcem.xm.ticket.controller.param.ticket.config;

import com.bestcem.xm.ticket.enums.TicketFlowMatchConditionEnum;
import com.bestcem.xm.ticket.enums.TicketFlowStatusEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * UpdateTicketFlowParam
 *
 * @author zh.zhang <zh.zhang@idiaoyan.com>
 * @date 2021-09-08
 * @version v1.0
 */
public class UpdateTicketFlowParam {

    @JsonProperty("record_flag")
    private Integer recordFlag = 1;

    @JsonProperty("createdDT")
    @JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
    private Date createdDate;

    @JsonProperty("createdID")
    private String createdId;

    @JsonProperty("updatedDT")
    @JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
    private Date updatedDate;

    @JsonProperty("updatedID")
    private String updatedId;

    /**
     * orgId
     */
    @JsonProperty("orgId")
    private String orgId;

    /**
     * userId
     */
    @JsonProperty("userId")
    private String userId;

    /**
     * ticketConfigId
     */
    @JsonProperty("ticketConfigId")
    private String ticketConfigId;

    /**
     * flowId 工单流程序列号
     */
    @JsonProperty("flowId")
    private Integer flowId;

    /**
     * title
     */
    @JsonProperty("title")
    private String title;

    /**
     * status
     *
     * @see TicketFlowStatusEnum
     */
    @JsonProperty("status")
    private Integer status;

    /**
     * matchCondition
     *
     * @see TicketFlowMatchConditionEnum
     */
    @JsonProperty("matchCondition")
    private Integer matchCondition;

    /**
     * alertRuleIds ObjectId 数组
     */
    @JsonProperty("alertRuleIds")
    private List<String> alertRuleIds;

    /**
     * customRuleIds
     */
    @JsonProperty("customRuleIds")
    private List<CustomRuleId> customRuleIds;

    /**
     * priority 工单流程的优先级 数字越小优先级越高
     */
    @JsonProperty("priority")
    private Integer priority;

    /**
     * 保存每个跟进人的详细配置, 注意数组内元素的顺序, 第一个元素就是第一跟进人, 第二个就是第二跟进人, 最多两个跟进人
     */
    @JsonProperty("followConfig")
    private List<FollowConfig> followConfig;

    /**
     * 工单是否需要审核
     */
    @JsonProperty("needAudit")
    private Boolean needAudit;

    /**
     * auditConfig
     */
    @JsonProperty("auditConfig")
    private List<FollowConfig> auditConfig;

    /**
     * version
     */
    @JsonProperty("version")
    private Integer version;

    /**
     * 工单流程规则列表
     */
    @JsonProperty("ruleList")
    private List<String> ruleList;

    /**
     * CustomRuleId
     */
    @Data
    public static class CustomRuleId {
        /**
         * id
         */
        @JsonProperty("id")
        private String id;

        /**
         * title
         */
        @JsonProperty("title")
        private String title;
    }

    /**
     * FollowConfig
     */
    @Data
    public static class FollowConfig {
        /**
         * title
         */
        @JsonProperty("title")
        private String title;

        /**
         * follower_email
         */
        @JsonProperty(value = "follower_email")
        private String followerEmail;

        /**
         * follower_id
         */
        @JsonProperty(value = "follower_id")
        private String followerId;

        /**
         * follower_name
         */
        @JsonProperty(value = "follower_name")
        private String followerName;

        /**
         * follower_filter
         */
        @JsonProperty(value = "follower_filter")
        private Integer followerFilter;

        /**
         * region
         */
        @JsonProperty("region")
        private String region;

        /**
         * roleId
         */
        @JsonProperty("roleId")
        private String roleId;

        /**
         * timeLimitType
         */
        @JsonProperty("timeLimitType")
        private Integer timeLimitType;

        /**
         * timeLimit
         */
        @JsonProperty("timeLimit")
        private String timeLimit;

        /**
         * overdueHandle
         */
        @JsonProperty("overdueHandle")
        private Integer overdueHandle;

        /**
         * emptyFollowerHandle
         */
        @JsonProperty("emptyFollowerHandle")
        private Integer emptyFollowerHandle;

        /**
         * options
         */
        @JsonProperty("options")
        private List<Option> options;


        @Data
        public static class Option {
            /**
             * id
             */
            @JsonProperty("id")
            private String id;

            /**
             * title
             */
            @JsonProperty("title")
            private String title;

            /**
             * role_index
             */
            @JsonProperty(value = "role_index")
            private String roleIndex;

            /**
             * roleType
             */
            @JsonProperty("roleType")
            private Integer roleType;
        }
    }

}
